package cn.appsys.service.appversion;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.appsys.dao.appinfo.AppInfoMapper;
import cn.appsys.dao.appversion.VersionMapper;
import cn.appsys.pojo.AppVersion;
/**
 * 版本业务实现层
 * @author 寇超强
 *
 */
@Service
public class VersionServiceImpl implements VersionService{

	@Resource
	private VersionMapper versionMapper;
	@Resource
	private AppInfoMapper appInfoMapper;
	
	@Override
	public List<AppVersion> getAppVersion(Integer id) {
		// TODO Auto-generated method stub
		return versionMapper.getAppVersion(id);
	}
	@Override
	public boolean addVersion(AppVersion version,Integer appId) throws Exception {
		//增加App版本信息
		
		if(versionMapper.addVersion(version,appId)>0){
			//修改app版本为最新版本
			appInfoMapper.updateVersionId(appId, version.getId());
			return true;
		}
		return false;
	}
	@Override
	public boolean updateVersion(AppVersion version) {
		// TODO Auto-generated method stub
		return versionMapper.updateVersion(version)>0 ? true :false ;
	}
	@Override
	public AppVersion getAppVersionById(Integer id) {
		// TODO Auto-generated method stub
		return versionMapper.getAppVersionById(id);
	}
	@Override
	public boolean updateVersionLogById(Integer id) {
		// TODO Auto-generated method stub
		return versionMapper.updateVersionLogById(id)>0? true :false;
	}
	@Override
	public boolean delVersion(Integer appInfoId) {
		// TODO Auto-generated method stub
		return versionMapper.delVersion(appInfoId)>0 ?true :false;
	}

}
